package com.hello.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hello.sky.annotation.AutoFill;
import com.hello.sky.enmu.OperationType;
import com.hello.sky.model.dto.ShoppingCartDTO;
import com.hello.sky.model.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 购物车 Mapper 接口
 * </p>
 *
 * @author D
 */
@Mapper
public interface ShoppingCartMapper extends BaseMapper<ShoppingCart> {


    ShoppingCart selectListByCart(ShoppingCart shoppingCart);

    @AutoFill(OperationType.INSERT)
    void addIntoCart(@Param("shoppingCart") ShoppingCart shoppingCart);

    @AutoFill(OperationType.UPDATE)
    void updateItemNumber(@Param("shoppingCart") ShoppingCart shoppingCart);

    List<ShoppingCart> selectByUserId(@Param("userId") Long userId);

    @AutoFill(OperationType.UPDATE)
    void delItem(ShoppingCart shoppingCart);


    void subItem(ShoppingCart shoppingCart);

    void cleanCart(@Param("userId") Long userId);

    @AutoFill(OperationType.INSERT)
    void insertBatch(@Param("cartList") List<ShoppingCart> cartList);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void delBatchByUserId(@Param("userId") Long userId);
}
